package com.control.action;

import com.model.entity.Student;
import com.model.imp.StudentImp;
import com.opensymphony.xwork2.ActionContext;

public class FindStudentAction {
   private String studentNumber;
   private String studentName;
	
	
	public String getStudentNumber() {
	return studentNumber;
}



public void setStudentNumber(String studentNumber) {
	this.studentNumber = studentNumber;
}



public String getStudentName() {
	return studentName;
}



public void setStudentName(String studentName) {
	this.studentName = studentName;
}

	public String findStudent()
    throws Exception{
		System.out.println(studentName);
		System.out.println(studentNumber);
	    ActionContext cxct=ActionContext.getContext();
		if(!studentName.equals("")){
			    StudentImp sp=new StudentImp();
				Student student=sp.findByName(studentName);
				System.out.println("studentName");
				if(student!=null){
				  cxct.put("student", student);
					return "studentdetail";  
				}else {
					return "list";
					}
		}
		if(!studentNumber.equals("")){
			
			 StudentImp sp=new StudentImp();
			 Student student=sp.findByNumber(studentNumber);
			 //System.out.println(student.getBirthday().toString());
			 System.out.println("studentNumber");
			 if(student!=null){
				 System.out.println("student");
				 cxct.put("student", student);
				   return "studentdetail";
				}
		    else{	
		    	System.out.println("list");
		    	return "list";	
	     	}
	  
		}
		
		return "list";
	}
	
	
	
	public String execute()
    throws Exception{
		
		return "succuss";
	}
	
	
}
